package com.szqhyxj.youxiangju.biz.documentphoto;

import com.bumptech.glide.Glide;
import com.szqhyxj.youxiangju.sys.BaseResult;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by leung on 2018/11/1.
 */

public class DocumentPhotoPresenter implements DocumentPhotoContract.Presenter {
    DocumentPhotoContract.View view;

    public DocumentPhotoPresenter(DocumentPhotoContract.View view) {
        this.view = view;
    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void picUrl() {
        DocumentPhotoModel.documentPhoto()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<BaseResult<DocumentPhotoModel.DocumentPhotoEntity>>() {
                    @Override
                    public void accept(BaseResult<DocumentPhotoModel.DocumentPhotoEntity> documentPhotoEntityBaseResult) throws Exception {
                        if (documentPhotoEntityBaseResult.businessLogicSuccess()){
                            view.showIcCardFace(documentPhotoEntityBaseResult.getData().getIdCardFacepic());
                            view.showIcCardBack(documentPhotoEntityBaseResult.getData().getIdCardBackpic());
                            view.showCreditCard(documentPhotoEntityBaseResult.getData().getBankCardPic());
                            view.showHandheldIdCard(documentPhotoEntityBaseResult.getData().getHandIdCard());
                        }else {
                            view.showToast(documentPhotoEntityBaseResult.getMessage());
                        }


                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        view.showToast(throwable.getMessage());
                    }
                });
    }

    @Override
    public void icCardFace() {

    }

    @Override
    public void icCardBack() {

    }
}
